/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.epos.datalogic.define.dao;

import cn.ekuma.data.dao.BaseDAO;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.format.Formats;
import com.openbravo.pos.base.AppLocal;
import com.openbravo.bean.SharedProduct;

/**
 *
 * @author Administrator
 */
public class SharedProductDAO extends BaseDAO<SharedProduct>{

    public SharedProductDAO(I_Session s) {
        super(s);
    }

    @Override
    public TableDefinition getTable() {
        return new TableDefinition(s,
                "SHAREDPRODUCTS",
                new String[]{ "PRODUCT", "ATTRIBUTESETINSTANCE_ID", "UNITS"},
                new String[]{ "Label.Name","",""},
                new Datas[]{ Datas.STRING, Datas.STRING, Datas.DOUBLE},
                new Formats[]{Formats.STRING, Formats.STRING, Formats.DOUBLE},
                new int[]{0});
    }

    @Override
    public void writeInsertValues(DataWrite dp, SharedProduct obj) throws BasicException {
          dp.setString(1, obj.getProductId());
          dp.setString(2, obj.getAttsetinstid());
          dp.setDouble(3, obj.getNum());
    }

    public SharedProduct readValues(DataRead dr,SharedProduct obj) throws BasicException {
        if(obj==null)
        	obj=new SharedProduct();
        obj.setProductId(dr.getString(1));
        obj.setAttsetinstid(dr.getString(2));
        obj.setNum(dr.getDouble(3));
    	return obj;
    }

    @Override
    public Class getSuportClass() {
        return SharedProduct.class;
    }


}
